<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>Electron-Vue实战——1、环境搭建 | 方塘</title>
    <meta name="description" content="半亩方塘 记录点滴">
    <meta name="generator" content="VuePress 1.4.0">
    <link rel="icon" href="/pond/favicon.ico">
  <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no">
    
    <link rel="preload" href="/pond/assets/css/0.styles.e7d3875b.css" as="style"><link rel="preload" href="/pond/assets/js/app.ae40f477.js" as="script"><link rel="preload" href="/pond/assets/js/3.4dddd738.js" as="script"><link rel="preload" href="/pond/assets/js/1.78b3a486.js" as="script"><link rel="preload" href="/pond/assets/js/12.1d51f447.js" as="script"><link rel="prefetch" href="/pond/assets/js/10.60d30c62.js"><link rel="prefetch" href="/pond/assets/js/11.2f15c6a5.js"><link rel="prefetch" href="/pond/assets/js/13.814b881d.js"><link rel="prefetch" href="/pond/assets/js/14.0cad3209.js"><link rel="prefetch" href="/pond/assets/js/15.1f5f9717.js"><link rel="prefetch" href="/pond/assets/js/16.76e81153.js"><link rel="prefetch" href="/pond/assets/js/17.b69f6fef.js"><link rel="prefetch" href="/pond/assets/js/18.8b657c1a.js"><link rel="prefetch" href="/pond/assets/js/19.7b986df4.js"><link rel="prefetch" href="/pond/assets/js/20.dcaf37b7.js"><link rel="prefetch" href="/pond/assets/js/4.cd37660a.js"><link rel="prefetch" href="/pond/assets/js/5.066fd35c.js"><link rel="prefetch" href="/pond/assets/js/6.34341067.js"><link rel="prefetch" href="/pond/assets/js/7.05fd4dd8.js"><link rel="prefetch" href="/pond/assets/js/8.5a84398b.js"><link rel="prefetch" href="/pond/assets/js/9.af98ea9c.js">
    <link rel="stylesheet" href="/pond/assets/css/0.styles.e7d3875b.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div><div class="theme-container" data-v-319dd33c><div data-v-319dd33c><div id="loader-wrapper" class="loading-wrapper" data-v-4b73742e data-v-319dd33c data-v-319dd33c><div class="loader-main" data-v-4b73742e><div data-v-4b73742e></div><div data-v-4b73742e></div><div data-v-4b73742e></div><div data-v-4b73742e></div></div> <!----> <!----></div> <div class="password-shadow password-wrapper-out" style="display:none;" data-v-1e2a0cc0 data-v-319dd33c data-v-319dd33c><h3 class="title" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0>方塘</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0><input type="password" value="" data-v-1e2a0cc0> <span data-v-1e2a0cc0>Konck! Knock!</span> <button data-v-1e2a0cc0>OK</button></label> <div class="footer" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0><span data-v-1e2a0cc0><i class="iconfont reco-theme" data-v-1e2a0cc0></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-1e2a0cc0>vuePress-theme-reco</a></span> <span data-v-1e2a0cc0><i class="iconfont reco-copyright" data-v-1e2a0cc0></i> <a data-v-1e2a0cc0><span data-v-1e2a0cc0>zenos</span>
            
          <span data-v-1e2a0cc0>2017 - </span>
          2020
        </a></span></div></div> <div class="hide" data-v-319dd33c><header class="navbar" data-v-319dd33c><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/pond/" class="home-link router-link-active"><img src="/pond/logo.png" alt="方塘" class="logo"> <span class="site-name">方塘</span></a> <div class="links"><div class="color-picker"><a class="color-button"><i class="iconfont reco-color"></i></a> <div class="color-picker-menu" style="display:none;"><div class="mode-options"><h4 class="title">Choose mode</h4> <ul class="color-mode-options"><li class="dark">dark</li><li class="auto active">auto</li><li class="light">light</li></ul></div></div></div> <div class="search-box"><i class="iconfont reco-search"></i> <input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/pond/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pond/categories/Git/" class="nav-link"><i class="iconfont undefined"></i>
  Git
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Electron/" class="nav-link"><i class="iconfont undefined"></i>
  Electron
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Java/问题解决/" class="nav-link"><i class="iconfont undefined"></i>
  Java/问题解决
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Nginx/" class="nav-link"><i class="iconfont undefined"></i>
  Nginx
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Vue/问题解决/" class="nav-link"><i class="iconfont undefined"></i>
  Vue/问题解决
</a></li></ul></div></div><div class="nav-item"><a href="/pond/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><a href="/pond/life/photo.html" class="nav-link"><i class="iconfont reco-message"></i>
  点滴
</a></div><div class="nav-item"><a href="/pond/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Contact
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.npmjs.com/~reco_luan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-npm"></i>
  NPM
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://github.com/recoluan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.jianshu.com/u/cd674a19515e" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-jianshu"></i>
  简书
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/zhlantian" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csdn"></i>
  CSDN
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.cnblogs.com/luanhewei/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-bokeyuan"></i>
  博客圆
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://mp.weixin.qq.com/s/mXFqeUTegdvPliXknAAG_A" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-wechat"></i>
  WeChat
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav></div></header> <div class="sidebar-mask" data-v-319dd33c></div> <aside class="sidebar" data-v-319dd33c><div class="personal-info-wrapper" data-v-6c8ffc9c><img src="/pond/avatar.png" alt="author-avatar" class="personal-img" data-v-6c8ffc9c> <h3 class="name" data-v-6c8ffc9c>
    zenos
  </h3> <div class="num" data-v-6c8ffc9c><div data-v-6c8ffc9c><h3 data-v-6c8ffc9c>7</h3> <h6 data-v-6c8ffc9c>文章</h6></div> <div data-v-6c8ffc9c><h3 data-v-6c8ffc9c>4</h3> <h6 data-v-6c8ffc9c>标签</h6></div></div> <hr data-v-6c8ffc9c></div> <nav class="nav-links"><div class="nav-item"><a href="/pond/" class="nav-link"><i class="iconfont reco-home"></i>
  Home
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-category"></i>
      Category
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/pond/categories/Git/" class="nav-link"><i class="iconfont undefined"></i>
  Git
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Electron/" class="nav-link"><i class="iconfont undefined"></i>
  Electron
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Java/问题解决/" class="nav-link"><i class="iconfont undefined"></i>
  Java/问题解决
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Nginx/" class="nav-link"><i class="iconfont undefined"></i>
  Nginx
</a></li><li class="dropdown-item"><!----> <a href="/pond/categories/Vue/问题解决/" class="nav-link"><i class="iconfont undefined"></i>
  Vue/问题解决
</a></li></ul></div></div><div class="nav-item"><a href="/pond/tag/" class="nav-link"><i class="iconfont reco-tag"></i>
  Tag
</a></div><div class="nav-item"><a href="/pond/life/photo.html" class="nav-link"><i class="iconfont reco-message"></i>
  点滴
</a></div><div class="nav-item"><a href="/pond/timeline/" class="nav-link"><i class="iconfont reco-date"></i>
  TimeLine
</a></div><div class="nav-item"><div class="dropdown-wrapper"><a class="dropdown-title"><span class="title"><i class="iconfont reco-message"></i>
      Contact
    </span> <span class="arrow right"></span></a> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://www.npmjs.com/~reco_luan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-npm"></i>
  NPM
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://github.com/recoluan" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-github"></i>
  GitHub
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.jianshu.com/u/cd674a19515e" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-jianshu"></i>
  简书
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://blog.csdn.net/zhlantian" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-csdn"></i>
  CSDN
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://www.cnblogs.com/luanhewei/" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-bokeyuan"></i>
  博客圆
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li><li class="dropdown-item"><!----> <a href="https://mp.weixin.qq.com/s/mXFqeUTegdvPliXknAAG_A" target="_blank" rel="noopener noreferrer" class="nav-link external"><i class="iconfont reco-wechat"></i>
  WeChat
  <svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></li></ul></div></div> <!----></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>Electron-Vue实战——1、环境搭建</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#electron-vue-介绍" class="sidebar-link">Electron-Vue 介绍</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#基本使用" class="sidebar-link">基本使用</a><ul class="sidebar-sub-headers"></ul></li><li><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#开始初始化" class="sidebar-link">开始初始化</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#附：nrm-常用指令" class="sidebar-link">附：nrm 常用指令</a></li></ul></li><li><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#开始填坑" class="sidebar-link">开始填坑</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#坑一、html-webpack-plugin-for-index-html-entrypoint-undefined-index-html" class="sidebar-link">坑一、html-webpack-plugin for &quot;index.html&quot;: Entrypoint undefined = index.html</a></li><li class="sidebar-sub-header"><a href="/pond/views/Electron/electron-vue%E5%AE%9E%E6%88%98%E2%80%94%E2%80%941%E3%80%81%E7%8E%AF%E5%A2%83%E6%90%AD%E5%BB%BA.html#坑二、process-is-not-defined" class="sidebar-link">坑二、process is not defined</a></li></ul></li></ul></section></li></ul> </aside> <div class="password-shadow password-wrapper-in" style="display:none;" data-v-1e2a0cc0 data-v-319dd33c><h3 class="title" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0>Electron-Vue实战——1、环境搭建</h3> <!----> <label id="box" class="inputBox" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0><input type="password" value="" data-v-1e2a0cc0> <span data-v-1e2a0cc0>Konck! Knock!</span> <button data-v-1e2a0cc0>OK</button></label> <div class="footer" style="display:none;" data-v-1e2a0cc0 data-v-1e2a0cc0><span data-v-1e2a0cc0><i class="iconfont reco-theme" data-v-1e2a0cc0></i> <a target="blank" href="https://vuepress-theme-reco.recoluan.com" data-v-1e2a0cc0>vuePress-theme-reco</a></span> <span data-v-1e2a0cc0><i class="iconfont reco-copyright" data-v-1e2a0cc0></i> <a data-v-1e2a0cc0><span data-v-1e2a0cc0>zenos</span>
            
          <span data-v-1e2a0cc0>2017 - </span>
          2020
        </a></span></div></div> <div data-v-319dd33c><main class="page"><div class="page-title" style="display:none;"><h1>Electron-Vue实战——1、环境搭建</h1> <hr> <div data-v-484a899e><i class="iconfont reco-account" data-v-484a899e><span data-v-484a899e>zenos</span></i> <i class="iconfont reco-date" data-v-484a899e><span data-v-484a899e>2020-06-09</span></i> <!----> <i class="iconfont reco-tag tags" data-v-484a899e><span class="tag-item" data-v-484a899e>
      electron-vue
    </span></i></div></div> <div class="theme-reco-content content__default" style="display:none;"><div class="custom-block tip"><p>本文主要记录 Electron 实战开发中，使用 electron-vue 模板搭建项目以及启动项目时遇到的各种坑</p></div> <h2 id="electron-vue-介绍"><a href="#electron-vue-介绍" class="header-anchor">#</a> Electron-Vue 介绍</h2> <p><a href="https://simulatedgreg.gitbooks.io/electron-vue/content/cn" target="_blank" rel="noopener noreferrer">electron-vue 官方文档<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h2 id="基本使用"><a href="#基本使用" class="header-anchor">#</a> 基本使用</h2> <p>具体请参考官方文档的<code>起步</code>部分</p> <div class="language- line-numbers-mode"><pre class="language-text"><code># 安装 vue-cli 和 脚手架样板代码
npm install -g vue-cli
vue init simulatedgreg/electron-vue my-project

# 安装依赖并运行你的程序
cd my-project
yarn # 或者 npm install
yarn run dev # 或者 npm run dev
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><h2 id="开始初始化"><a href="#开始初始化" class="header-anchor">#</a> 开始初始化</h2> <p>在运行<code>npm install</code>之前，建议先将 npm 的仓库修改为使用淘宝镜像**（建议使用 nrm 进行管理）**，不然<code>chromedriver</code>、<code>node-sass</code>以及<code>electron</code>这几个包很可能下载失败。(个人使用淘宝镜像在家试了好多次都不成功，最终在公司才安装成功...泪目...)</p> <h3 id="附：nrm-常用指令"><a href="#附：nrm-常用指令" class="header-anchor">#</a> 附：nrm 常用指令</h3> <p>安装 nrm 管理，安装这个的前提是能确定链接到现在的镜像地址：</p> <p><code>npm install -g nrm</code></p> <p>待安装完 nrm 之后，通过 nrm 管理镜像的地址，一条命令切换，如：</p> <p><code>nrm use taobao</code></p> <p>nrm 除了淘宝站点镜像之外还有其他的，可以使用一下命令查看：</p> <p><code>nrm ls</code></p> <h2 id="开始填坑"><a href="#开始填坑" class="header-anchor">#</a> 开始填坑</h2> <p>好不容易下载好所有 node_modules 后，以为只需要简单的运行<code>npm run dev</code>就可以了，然而，我还是太天真........</p> <h3 id="坑一、html-webpack-plugin-for-index-html-entrypoint-undefined-index-html"><a href="#坑一、html-webpack-plugin-for-index-html-entrypoint-undefined-index-html" class="header-anchor">#</a> 坑一、html-webpack-plugin for &quot;index.html&quot;: Entrypoint undefined = index.html</h3> <h4 id="详细错误信息"><a href="#详细错误信息" class="header-anchor">#</a> 详细错误信息</h4> <div class="language-js line-numbers-mode"><pre class="language-js"><code>Child html<span class="token operator">-</span>webpack<span class="token operator">-</span>plugin <span class="token keyword">for</span> <span class="token string">&quot;index.html&quot;</span><span class="token operator">:</span>
Asset Size Chunks Chunk Names
index<span class="token punctuation">.</span>html <span class="token number">5.53</span> KiB <span class="token number">0</span>
Entrypoint <span class="token keyword">undefined</span> <span class="token operator">=</span> index<span class="token punctuation">.</span>html
<span class="token punctuation">[</span><span class="token punctuation">.</span><span class="token operator">/</span>node_modules<span class="token operator">/</span>html<span class="token operator">-</span>webpack<span class="token operator">-</span>plugin<span class="token operator">/</span>lib<span class="token operator">/</span>loader<span class="token punctuation">.</span>js<span class="token operator">!</span><span class="token punctuation">.</span><span class="token operator">/</span>src<span class="token operator">/</span>index<span class="token punctuation">.</span>ejs<span class="token punctuation">]</span> <span class="token number">1.06</span> KiB <span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span> <span class="token punctuation">[</span>built<span class="token punctuation">]</span><span class="token punctuation">[</span>failed<span class="token punctuation">]</span> <span class="token punctuation">[</span><span class="token number">1</span> error<span class="token punctuation">]</span>

      <span class="token constant">ERROR</span> <span class="token keyword">in</span> <span class="token punctuation">.</span><span class="token operator">/</span>src<span class="token operator">/</span>index<span class="token punctuation">.</span><span class="token function">ejs</span> <span class="token punctuation">(</span><span class="token punctuation">.</span><span class="token operator">/</span>node_modules<span class="token operator">/</span>html<span class="token operator">-</span>webpack<span class="token operator">-</span>plugin<span class="token operator">/</span>lib<span class="token operator">/</span>loader<span class="token punctuation">.</span>js<span class="token operator">!</span><span class="token punctuation">.</span><span class="token operator">/</span>src<span class="token operator">/</span>index<span class="token punctuation">.</span>ejs<span class="token punctuation">)</span>
      Module build <span class="token function">failed</span> <span class="token punctuation">(</span><span class="token keyword">from</span> <span class="token punctuation">.</span><span class="token operator">/</span>node_modules<span class="token operator">/</span>html<span class="token operator">-</span>webpack<span class="token operator">-</span>plugin<span class="token operator">/</span>lib<span class="token operator">/</span>loader<span class="token punctuation">.</span>js<span class="token punctuation">)</span><span class="token operator">:</span>
      SyntaxError<span class="token operator">:</span> Invalid or unexpected token
          at <span class="token function">Function</span> <span class="token punctuation">(</span><span class="token operator">&lt;</span>anonymous<span class="token operator">&gt;</span><span class="token punctuation">)</span>
          at <span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">14870</span><span class="token operator">:</span><span class="token number">16</span>
          at <span class="token function">apply</span> <span class="token punctuation">(</span><span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">473</span><span class="token operator">:</span><span class="token number">27</span><span class="token punctuation">)</span>
          at <span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">15254</span><span class="token operator">:</span><span class="token number">16</span>
          at <span class="token function">apply</span> <span class="token punctuation">(</span><span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">475</span><span class="token operator">:</span><span class="token number">27</span><span class="token punctuation">)</span>
          at <span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">6563</span><span class="token operator">:</span><span class="token number">16</span>
          at Function<span class="token punctuation">.</span><span class="token function">template</span> <span class="token punctuation">(</span><span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\lodash\lodash<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">14869</span><span class="token operator">:</span><span class="token number">20</span><span class="token punctuation">)</span>
          at Object<span class="token punctuation">.</span>module<span class="token punctuation">.</span><span class="token function">exports</span> <span class="token punctuation">(</span><span class="token constant">E</span><span class="token operator">:</span>\学习相关\Electron\practice\electron<span class="token operator">-</span>spider\node_modules\html<span class="token operator">-</span>webpack<span class="token operator">-</span>plugin\lib\loader<span class="token punctuation">.</span>js<span class="token operator">:</span><span class="token number">28</span><span class="token operator">:</span><span class="token number">22</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br></div></div><h4 id="错误表现"><a href="#错误表现" class="header-anchor">#</a> 错误表现</h4> <p>显示为项目文件浏览器</p> <h4 id="解决方法"><a href="#解决方法" class="header-anchor">#</a> 解决方法</h4> <p>GitHub 上对应的 issue<a href="https://github.com/SimulatedGREG/electron-vue/issues/907" target="_blank" rel="noopener noreferrer">907<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <p>自己尝试尝试了很久，一直没有解决，后来在<code>.eslintignore</code>中添加了<code>*.ejs</code>后突然解决了，(依据：ejs 中的标签'&lt;'和'!'在 eslint 中报错)后续再将添加的<code>*.ejs</code>注释掉，仍然可以运行，有点迷惑</p> <h3 id="坑二、process-is-not-defined"><a href="#坑二、process-is-not-defined" class="header-anchor">#</a> 坑二、process is not defined</h3> <p>GitHub 上 issue 有明确描述<a href="https://github.com/SimulatedGREG/electron-vue/issues/871" target="_blank" rel="noopener noreferrer">issue 871<svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg></a></p> <h4 id="解决方法-2"><a href="#解决方法-2" class="header-anchor">#</a> 解决方法</h4> <p>方法一：在 index.ejs 中修改将<code>process.browser</code>修改为<code>require('process').browser</code></p> <div class="language-js line-numbers-mode"><pre class="language-js"><code> <span class="token operator">&lt;</span><span class="token operator">%</span> <span class="token keyword">if</span> <span class="token punctuation">(</span><span class="token operator">!</span><span class="token function">require</span><span class="token punctuation">(</span><span class="token string">'process'</span><span class="token punctuation">)</span><span class="token punctuation">.</span>browser<span class="token punctuation">)</span> <span class="token punctuation">{</span> <span class="token operator">%</span><span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span>script<span class="token operator">&gt;</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>process<span class="token punctuation">.</span>env<span class="token punctuation">.</span><span class="token constant">NODE_ENV</span> <span class="token operator">!==</span> <span class="token string">&quot;development&quot;</span><span class="token punctuation">)</span>
        window<span class="token punctuation">.</span>__static <span class="token operator">=</span> <span class="token function">require</span><span class="token punctuation">(</span><span class="token string">&quot;path&quot;</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">join</span><span class="token punctuation">(</span>__dirname<span class="token punctuation">,</span> <span class="token string">&quot;/static&quot;</span><span class="token punctuation">)</span>
          <span class="token punctuation">.</span><span class="token function">replace</span><span class="token punctuation">(</span><span class="token regex">/\\/g</span><span class="token punctuation">,</span> <span class="token string">&quot;\\\\&quot;</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
    <span class="token operator">&lt;</span><span class="token operator">/</span>script<span class="token operator">&gt;</span>
    <span class="token operator">&lt;</span><span class="token operator">%</span> <span class="token punctuation">}</span> <span class="token operator">%</span><span class="token operator">&gt;</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br></div></div><p>方法二：在<code>.electron-vue/webpack.web.config.js</code> and <code>.electron-vue/webpack.renderer.config.js</code>中添加<code>templateParameters</code>部分的配置:</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">new</span> <span class="token class-name">HtmlWebpackPlugin</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
      filename<span class="token operator">:</span> <span class="token string">'index.html'</span><span class="token punctuation">,</span>
      template<span class="token operator">:</span> path<span class="token punctuation">.</span><span class="token function">resolve</span><span class="token punctuation">(</span>__dirname<span class="token punctuation">,</span> <span class="token string">'../src/index.ejs'</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
      <span class="token function">templateParameters</span><span class="token punctuation">(</span><span class="token parameter">compilation<span class="token punctuation">,</span> assets<span class="token punctuation">,</span> options</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token keyword">return</span> <span class="token punctuation">{</span>
          compilation<span class="token operator">:</span> compilation<span class="token punctuation">,</span>
          webpack<span class="token operator">:</span> compilation<span class="token punctuation">.</span><span class="token function">getStats</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">.</span><span class="token function">toJson</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
          webpackConfig<span class="token operator">:</span> compilation<span class="token punctuation">.</span>options<span class="token punctuation">,</span>
          htmlWebpackPlugin<span class="token operator">:</span> <span class="token punctuation">{</span>
            files<span class="token operator">:</span> assets<span class="token punctuation">,</span>
            options<span class="token operator">:</span> options
          <span class="token punctuation">}</span><span class="token punctuation">,</span>
          process<span class="token punctuation">,</span>
        <span class="token punctuation">}</span><span class="token punctuation">;</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
      minify<span class="token operator">:</span> <span class="token punctuation">{</span>
        collapseWhitespace<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
        removeAttributeQuotes<span class="token operator">:</span> <span class="token boolean">true</span><span class="token punctuation">,</span>
        removeComments<span class="token operator">:</span> <span class="token boolean">true</span>
      <span class="token punctuation">}</span><span class="token punctuation">,</span>
      nodeModules<span class="token operator">:</span> <span class="token boolean">false</span>
    <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">,</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br><span class="line-number">16</span><br><span class="line-number">17</span><br><span class="line-number">18</span><br><span class="line-number">19</span><br><span class="line-number">20</span><br><span class="line-number">21</span><br><span class="line-number">22</span><br></div></div></div> <footer class="page-edit" style="display:none;"><!----> <!----></footer> <!----></main> <!----> <div style="display:none;" data-v-319dd33c data-v-319dd33c><div class="comments-wrapper" data-v-319dd33c><!----></div></div></div></div></div></div></div><div class="global-ui"><div class="back-to-ceiling" style="right:1rem;bottom:6rem;width:2.5rem;height:2.5rem;border-radius:.25rem;line-height:2.5rem;display:none;" data-v-a81d141e data-v-a81d141e><svg t="1574745035067" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="5404" class="icon" data-v-a81d141e><path d="M526.60727968 10.90185116a27.675 27.675 0 0 0-29.21455937 0c-131.36607665 82.28402758-218.69155461 228.01873535-218.69155402 394.07834331a462.20625001 462.20625001 0 0 0 5.36959153 69.94390903c1.00431239 6.55289093-0.34802892 13.13561351-3.76865779 18.80351572-32.63518765 54.11355614-51.75690182 118.55860487-51.7569018 187.94566865a371.06718723 371.06718723 0 0 0 11.50484808 91.98906777c6.53300375 25.50556257 41.68394495 28.14064038 52.69160883 4.22606766 17.37162448-37.73630017 42.14135425-72.50938081 72.80769204-103.21549295 2.18761121 3.04276886 4.15646224 6.24463696 6.40373557 9.22774369a1871.4375 1871.4375 0 0 0 140.04691725 5.34970492 1866.36093723 1866.36093723 0 0 0 140.04691723-5.34970492c2.24727335-2.98310674 4.21612437-6.18497483 6.3937923-9.2178004 30.66633723 30.70611158 55.4360664 65.4791928 72.80769147 103.21549355 11.00766384 23.91457269 46.15860503 21.27949489 52.69160879-4.22606768a371.15156223 371.15156223 0 0 0 11.514792-91.99901164c0-69.36717486-19.13165746-133.82216804-51.75690182-187.92578088-3.42062944-5.66790279-4.76302748-12.26056868-3.76865837-18.80351632a462.20625001 462.20625001 0 0 0 5.36959269-69.943909c-0.00994388-166.08943902-87.32547796-311.81420293-218.6915546-394.09823051zM605.93803103 357.87693858a93.93749974 93.93749974 0 1 1-187.89594924 6.1e-7 93.93749974 93.93749974 0 0 1 187.89594924-6.1e-7z" p-id="5405" data-v-a81d141e></path><path d="M429.50777625 765.63860547C429.50777625 803.39355007 466.44236686 1000.39046097 512.00932183 1000.39046097c45.56695499 0 82.4922232-197.00623328 82.5015456-234.7518555 0-37.75494459-36.9345906-68.35043303-82.4922232-68.34111062-45.57627738-0.00932239-82.52019037 30.59548842-82.51086798 68.34111062z" p-id="5406" data-v-a81d141e></path></svg></div><div class="kanbanniang" data-v-5775ee02><div class="banniang-container" style="display:;" data-v-5775ee02><div class="messageBox" style="right:68px;bottom:190px;display:none;" data-v-5775ee02>
      欢迎来到 方塘
    </div> <div class="operation" style="right:90px;bottom:40px;display:;" data-v-5775ee02><i class="kbnfont kbn-ban-home ban-home" data-v-5775ee02></i> <i class="kbnfont kbn-ban-message message" data-v-5775ee02></i> <i class="kbnfont kbn-ban-close close" data-v-5775ee02></i> <a target="_blank" href="https://vuepress-theme-reco.recoluan.com/views/plugins/kanbanniang.html" data-v-5775ee02><i class="kbnfont kbn-ban-info info" data-v-5775ee02></i></a> <i class="kbnfont kbn-ban-theme skin" style="display:none;" data-v-5775ee02></i></div> <canvas id="banniang" width="150" height="220" class="live2d" style="position:fixed;left:0px;bottom:0px;opacity:0.9;z-index:99999;" data-v-5775ee02></canvas></div> <div class="showBanNiang" style="display:none;" data-v-5775ee02>
    看板娘
  </div></div></div></div>
    <script src="/pond/assets/js/app.ae40f477.js" defer></script><script src="/pond/assets/js/3.4dddd738.js" defer></script><script src="/pond/assets/js/1.78b3a486.js" defer></script><script src="/pond/assets/js/12.1d51f447.js" defer></script>
  </body>
</html>
